// pages/highRisk/HighRisk.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

    longitude: "",
    latitude: "",
    markers: [],

  },


  backLocation: function (e) {
    const that = this
    let mpCtx = wx.createMapContext('map', this)
    mpCtx.moveToLocation()
    that.getLocation()
    that.getPointsNearVisitor()
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    const that = this
    that.setData({
      latitude: getApp().globalData.lati,
      longitude: getApp().globalData.long
    })
    wx.cloud.callFunction({
      name: 'doPost',
      data: {
        url: getApp().globalData.url + '/user/findAllRiskArea',
        info: "",
        token: getApp().globalData.token
      },
    }).then(res => {
      console.log(res.result)
      let markers = []
      let list = res.result
      for (let i = 0; i < list.length; i++) {
        markers.push({
          "id": i,
          "latitude": list[i].latitude,
          "longitude": list[i].longitude,
          "width": 30,
          "height": 40,
          "callout": {
            content: "记录编号:" + list[i].areaId + "\n" + "地点:" + list[i].address + "\n"
              + "确诊人数:" + list[i].count,
            padding: 10,
            display: 'BYCLICK',
            textAlign: 'center'
          }
        })
      }
      that.markers = markers
      that.setData({
        markers:markers
      })
    }).catch(res => {
      console.log(res)
      wx.showModal({
        title: "提示",
        content: "marker获取失败!"
      })
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})